package com.gss.plugin.doc.properties;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.net.URL;


/**
 * @author: DYang
 * @since: 2023/8/16
 * @description:
 */
@Deprecated
@Data
@AllArgsConstructor
@NoArgsConstructor
@Configuration
@ConfigurationProperties(prefix = "smart-doc")
public class ApiDocProperties {

    /**
     * 接口地址
     */
    private String serverUrl;

    /**
     * 端口
     */
    @Value("${server.port}")
    private int port;
    /**
     * 指定文档的输出路径，生成到项目静态文件目录下，随项目启动可以查看
     */
    private String outPath = "static/doc/api";
    /**
     * 是否开启严格模式
     */
    private boolean isStrict = false;

    /**
     * 是否将文档合并到一个文件中
     */
    private boolean allInOne = true;
    /**
     * 是否创建可以测试的html页面
     */
    private boolean createDebugPage = true;
    /**
     * controller包过滤
     */
    private String packageFilters;
    /**
     * 基于highlight.js的代码高设置
     */
    private String style = "xt256";
    /**
     * 项目名称
     */
    @Value("${spring.application.name}")
    private String projectName;
    /**
     * 是否显示接口作者名称
     */
    private boolean showAuthor = false;
    /**
     * 自定义设置输出文档名称
     */
    private String allInOneDocFileName = "doc.html";

    public void setPort(int port) {
        this.port = port;
        this.serverUrl = "http://localhost:" + port;
    }

    public void setOutPath(String outPath) {
        URL resource = ApiDocProperties.class.getClassLoader().getResource("");
        this.outPath = resource.getPath().substring(1) + outPath;
    }
}
